import {Message} from "element-ui";

export default {
  getCookie(name, cookie) {
    if(!cookie){
      return null;
    }
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");

    if (arr = cookie.match(reg)) return unescape(arr[2]);
    else return null;
  },
  showMessage(res) {
    if (res.code === 1) {
      Message.success(res.msg);
    } else {
      Message.error(res.msg);
    }
  },
  merge(source, target) {
    for (let key in target) {
      target[key] = source[key];
    }
    return target;
  }
}
